/*
  quattrans.h

% Version:  v0.7f
% Build:    8110521
% Date:     Nov-05 2008, 9:00 PM CET
% Author:   Jochen Weber, SCAN Unit, Columbia University, NYC, NY, USA
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

*/


/* quaternion transformation with simple variables */


/* variables */
#define QUATVARS    \
double  \
    qt11, qt12, qt13, qt14, \
    qt21, qt22, qt23, qt24, \
    qt31, qt32, qt33, qt34, \
    qtp1, qtp2;

/* get vars from 4x4 input */
#define GET_QUATVARS(PTR)   \
    qt11 = (double) *PTR++; \
    qt21 = (double) *PTR++; \
    qt31 = (double) *PTR++; \
    *PTR++;                 \
    qt12 = (double) *PTR++; \
    qt22 = (double) *PTR++; \
    qt32 = (double) *PTR++; \
    *PTR++;                 \
    qt13 = (double) *PTR++; \
    qt23 = (double) *PTR++; \
    qt33 = (double) *PTR++; \
    *PTR++;                 \
    qt14 = (double) *PTR++; \
    qt24 = (double) *PTR++; \
    qt34 = (double) *PTR++; \
    *PTR++;
 
/* multiplication */
#define QUAT_MULT(C1,C2,C3) \
    qtp1 = qt11 * C1 + qt12 * C2 + qt13 * C3 + qt14; \
    qtp2 = qt21 * C1 + qt22 * C2 + qt23 * C3 + qt24; \
      C3 = qt31 * C1 + qt32 * C2 + qt33 * C3 + qt34; \
      C1 = qtp1;  \
      C2 = qtp2;
#define QUAT_MULT_0B(C1,C2,C3) \
    qtp1 = qt11 * C1 + qt12 * C2 + qt13 * C3 + qt14 - 1.0; \
    qtp2 = qt21 * C1 + qt22 * C2 + qt23 * C3 + qt24 - 1.0; \
      C3 = qt31 * C1 + qt32 * C2 + qt33 * C3 + qt34 - 1.0; \
      C1 = qtp1;  \
      C2 = qtp2;
